import 'package:fluplu/getx.dart';
import 'package:fluplu/websocket.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class LoginPage extends StatefulWidget {
  const LoginPage({super.key});

  @override
  State<LoginPage> createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  final Controller logic = Get.put(Controller(), tag: "test");
  final Controller logic1 = Get.put(Controller());
  final Controller box = Get.find(tag: "test");

  final WebSocketController socket = Get.find();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("登录页")),
      body: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          GetBuilder<Controller>(
              tag: "test",
              builder: (logic) {
                return Text("Getx: ${logic.count}");
              }),
          GetBuilder<Controller>(builder: (logic) {
            return Text("Getx tag 不同，不会触发: ${logic.count}");
          }),
          const Text('登录页'),
        ],
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () {
          socket.send("test message");
          box.increment();
        },
        child: const Icon(Icons.add),
      ),
    );
  }
}
